<!DOCTYPE html>
<html lang="en">
<include file="Public/header" title="学生预报到" />


<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-content">
            	
		<!--预报到开始-->
		<table class="table table-striped table-bordered table-hover dataTables-example">
			<thead>
            <tr>
                <th>身份证</th>
                <th>学号</th>
                <th>学生姓名</th>
                <th>预报到</th>
            </tr>
            </thead>
            
            <tbody>
            <foreach name="res" item="val">
                <tr class="gradeX">
                    <td>{$val.idcard}</td>
                    <td>{$val.studentid}</td>
                    <td>{$val.studentname}</td>
                    <if condition="$val.forecast == 0">
                    	<td data-id="{$val.idcard}" data-did="{$val.idcard}">
			                <button id="submit" style="background-color: red;" class="btn btn-sm btn-info forecast" title="预报到" onclick="return confirm('请核对自己的信息！确认预报到吗？')">预报到</button>
		                </td>
                    	
                    	<else />
                    	
                    	<td><button class="btn btn-sm btn-info">已预报到</button></td>
                    </if>
                    
	            </tr>
           	</foreach>
            </tbody>
		</table>
		<!--预报到结束-->
		
			</div>
        </div>
    </div>
</div>
</div>
</body>


<script src="__PUBLIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/js/plugins/jeditable/jquery.jeditable.js"></script>
<script src="__PUBLIC__/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="__PUBLIC__/js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="__PUBLIC__/js/content.min.js?v=1.0.0"></script>
<!--<script>-->
    <!--$(document).ready(function(){$(".dataTables-example").dataTable();var oTable=$("#editable").dataTable();oTable.$("td").editable("http://www.zi-han.net/theme/example_ajax.php",{"callback":function(sValue,y){var aPos=oTable.fnGetPosition(this);oTable.fnUpdate(sValue,aPos[0],aPos[1])},"submitdata":function(value,settings){return{"row_id":this.parentNode.getAttribute("id"),"column":oTable.fnGetPosition(this)[2]}},"width":"90%","height":"100%"})});function fnClickAddRow(){$("#editable").dataTable().fnAddData(["Custom row","New row","New row","New row","New row"])};-->
<!--</script>-->
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script>
	$('#submit').on('click',function () {
        var btn = $(this);
        var idcard = btn.parent().data('id');
        console.log(idcard)
        var param = {
        	idcard: idcard
        };
        var url = "{:U('Student/forecast')}";
        $.ajax({
            url: url,
            data: param,
            dataType: 'json',
            type: 'post',
            success: function (data) {
                var dotr = btn.closest('tr');
                alert(data.info);
                if (data.status == 1) {
                	window.location.href="{:U('Student/index')}";
                    dotr.remove();
                }
            },
            error: function () {
                alert('操作失败');
            }
        })
    })
</script>
</html>